url = 'https://www.acwing.com/problem/content/4948/'

n,a = map(int,input().split())

a_list = list(map(int,input().split()))

    
m,b = map(int,input().split())
b_list = list(map(int,input().split()))

def n_to_ten(nums,n,x):
    res = 0
    for i in range(n):
        res += nums[i]*(x**(n-1-i))
    return res

a_n = n_to_ten(a_list,n,a)
b_n = n_to_ten(b_list,m,b)
# print(a_n,b_n)

if a_n > b_n:
    print('>')
elif a_n < b_n:
    print('<')
else:
    print('=')